package homework.printyourself.info.items;

import homework.printyourself.info.BaseObject;
import homework.valid.validators.ValidateChain;
import homework.valid.validators.impl.RegularValidator;

import java.io.IOException;

public class PhoneNumberItem extends BaseInformationItem {

    static {
        chain = new ValidateChain();
        chain.addValidator(new RegularValidator("手机号格式错误", "(?:\\+\\d{1,3})?1[3-8]\\d{9}"));
    }

    public PhoneNumberItem(BaseObject obj) throws IOException {
        super(obj, null);
        itemValue = (String)fi.input("请输入电话号码: ", chain);
        itemName = "电话";
    }

    public PhoneNumberItem(BaseObject obj, String value) {
        super(obj, value);
        itemName = "电话";
    }
}
